USE [NANS21V]
GO

/****** オブジェクト: Scalar Function [dbo].[Sokuteikubun] スクリプト日付: 2014/05/19 14:47:44 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

/****** Object:  UserDefinedFunction [dbo].[Sokuteikubun]    Script Date: 05/09/2014 15:48:19 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Sokuteikubun]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].[Sokuteikubun]
GO

CREATE FUNCTION [dbo].[Sokuteikubun]
(
	@KUBUN int
)
RETURNS VARCHAR(10)
AS
BEGIN
	DECLARE @return VARCHAR(10)

/*	IF @KUBUN = 1
		SET @return = '手動'
	ELSE IF @KUBUN = 2	
		SET @return = '電気'
	ELSE 
		SET @return = ''
*/

	select @return = MSG.TITLE from TBL_WEB_USE_ID ID,TBL_WEB_USE_MSG MSG
	WHERE LOWER(TAGNAME)=LOWER('MeasurementDivision') 
	AND ID.TAGID=MSG.TAGID
	AND MSG.XMLCODE=@KUBUN

	if @return is null 
	BEGIN
		SET @return = ''
	END


	RETURN @return
END